package com.aplikata.evok.datamodel;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.aplikata.evok.bo.PatientTherapyAttachment;
import com.aplikata.service.PublicService;
import com.aplikata.util.StringUtil;

/**
 * @ClassName: TherapyAttachmentDataModel
 * @Description: TODO
 * @author Huyun
 * @date May 30, 2012 9:46:24 PM
 */
public class TherapyAttachmentDataModel extends ListDataModel<PatientTherapyAttachment> implements
		SelectableDataModel<PatientTherapyAttachment> {
	private PublicService publicService;

	public TherapyAttachmentDataModel() {
	}

	public TherapyAttachmentDataModel(PublicService publicService, List<PatientTherapyAttachment> data) {
		super(data);
		this.publicService = publicService;
	}

	@Override
	public PatientTherapyAttachment getRowData(String arg0) {
		if (StringUtil.isStrEmpty(arg0) || "null".equals(arg0))
			return null;

		return (PatientTherapyAttachment) publicService.get(PatientTherapyAttachment.class, Long.parseLong(arg0));
	}

	@Override
	public Object getRowKey(PatientTherapyAttachment service) {
		return service.getId();
	}

	public PublicService getPublicService() {
		return publicService;
	}

	public void setPublicService(PublicService publicService) {
		this.publicService = publicService;
	}

}